package org.proddevplm.business.dataAccess;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.xml.crypto.Data;

import org.proddevplm.business.api.AController;
import org.proddevplm.business.dataAccess.constants.DataAccessConstants;
import org.proddevplm.constants.ControllerConstants;
import org.proddevplm.constants.UserConstants;
import org.proddevplm.dao.data.RelationMatrix;
import org.proddevplm.dao.data.Resource;
import org.proddevplm.dao.data.Roles;
import org.proddevplm.dao.data.User;
import org.proddevplm.dao.data.activities.Activity;
import org.proddevplm.dao.data.changeReport.ChangeReport;
import org.proddevplm.dao.data.competitors.Competitors;
import org.proddevplm.dao.data.competitors.CompetitorsProduct;
import org.proddevplm.dao.data.conceptSelection.PughAnalysis;
import org.proddevplm.dao.data.correlations.QFD;
import org.proddevplm.dao.data.designForX.DesignForX;
import org.proddevplm.dao.data.designForX.DfXGuidelines;
import org.proddevplm.dao.data.designForX.DfXImportances;
import org.proddevplm.dao.data.designForX.DfXRelMatrix;
import org.proddevplm.dao.data.designInputs.CTQs;
import org.proddevplm.dao.data.designInputs.DesignElements;
import org.proddevplm.dao.data.designInputs.ProductFunctions;
import org.proddevplm.dao.data.prioritize.AHPAnalysis;
import org.proddevplm.dao.data.productFollowUp.productionPhase.ManufacturingItinerary;
import org.proddevplm.dao.data.productFollowUp.productionPhase.Process;
import org.proddevplm.dao.data.productFollowUp.usePhase.Complaints;
import org.proddevplm.dao.data.productFollowUp.usePhase.Suggestions;
import org.proddevplm.dao.data.requirements.Requirements;
import org.proddevplm.dao.data.requirements.VOCTable;
import org.proddevplm.dao.data.stakeholders.Stakeholder;
import org.proddevplm.dao.data.swot.SwotAnalysis;

public class DataAccessController extends AController{

	@Override
	public Object execute(int command, Object data) {
		
		int projectId = (Integer) getSession().getAttribute("projectId");
		int productId = (Integer)getSession().getAttribute("productId");
		List<Competitors> competitorsByProduct;
		List<CompetitorsProduct> cpResults;
		List<Stakeholder> shResults;
		List<Stakeholder> sortedShResults = new ArrayList<Stakeholder>();
		Map<String, Object> dataAccessMap = (Map<String, Object>)data;
		List<Activity> activitiesForUser;
		User user = (User)getSession().getAttribute(UserConstants.USER);
		List<RelationMatrix> relMatrixUser = (List<RelationMatrix>) getSession().getAttribute("relMatrixUser");
		String currentRole = "";
		for (RelationMatrix r:relMatrixUser){
			if (r.getProject().getId()==projectId){
				Roles role = r.getRole();
				currentRole = role.getRole();
			}
		}
		
		switch(command){
		
		case DataAccessConstants.COMPETITORS:
			
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				String activityName = (String) dataAccessMap.get("activityName");
				List<CompetitorsProduct> cpByActivityName = getDaoManager().getDataAccessManager().getCPByActNameandProdId(activityName, productId);
				putOnSession("cpByActivityName", cpByActivityName);
			}
			
			competitorsByProduct = getDaoManager().getDataAccessManager().getCompetitorByProductId(productId);
			putOnSession("competitorsByProduct", competitorsByProduct);
			
			cpResults = getDaoManager().getDataAccessManager().getCompetitorsProductByProductId(productId);
	        putOnSession("cpResults", cpResults);
	        
	        putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.SWOT:
			
			competitorsByProduct = getDaoManager().getDataAccessManager().getCompetitorByProductId(productId);
			putOnSession("competitorsByProduct", competitorsByProduct);
			
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<SwotAnalysis> swotByActName = getDaoManager().getDataAccessManager().getSwotByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("swotByActName", swotByActName);
			}
						
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
	        putOnSession("currentTab", "tab5");
			break;
			
		case DataAccessConstants.SWOT_AJAX_CALL_1:
			String competitor = (String)dataAccessMap.get("competitor");
			String productsString = getDaoManager().getDataAccessManager().getCompetitorProductsByComp(competitor, productId);
			return productsString;
			
		case DataAccessConstants.SWOT_AJAX_CALL_2:
			String product = (String)dataAccessMap.get("product");
			String techCharString = getDaoManager().getDataAccessManager().getTechCharByProduct(product, productId);
			return techCharString;
			
		case DataAccessConstants.STAKEHOLDERS:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<Stakeholder> shByActName = getDaoManager().getDataAccessManager().getSHByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("shByActName", shByActName);
			}
			
			shResults = getDaoManager().getDataAccessManager().getStakeholdersByProductId(productId);
			putOnSession("shResults", shResults);
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
			break;
			
		case DataAccessConstants.NEEDS_REQS_MANAGER:
			System.out.println("Pagina manager");
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
			break;
			
		case DataAccessConstants.NEEDS_REQS_INTERN:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<Requirements> reqsByActName = getDaoManager().getDataAccessManager().getReqByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("reqsByActName", reqsByActName);
			}
			
			if(getSession().getAttribute("shResults")==null){
				shResults = getDaoManager().getDataAccessManager().getStakeholdersByProductId(productId);
			}
			else{
				shResults = (List<Stakeholder>)getSession().getAttribute("shResults");
			}
			for(Stakeholder sh:shResults){
				if((sh.getType()).equals("Internal")){
					sortedShResults.add(sh);
				}
			}
			putOnSession("sortedShResults", sortedShResults);
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
			break;
			
		case DataAccessConstants.MY_REQS:
			List<Requirements> myRequirements = getDaoManager().getDataAccessManager().getReqsByAuthorandProdId(user.getSurname()+" "+user.getName(), productId);
			putOnSession("myRequirements", myRequirements);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
			break;
			
		case DataAccessConstants.VIEW_ALL_REQS:
			
			if(getSession().getAttribute("shResults")==null){
				shResults = getDaoManager().getDataAccessManager().getStakeholdersByProductId(productId);
			}
			else{
				shResults = (List<Stakeholder>)getSession().getAttribute("shResults");
			}
			putOnSession("shResults", shResults);
			
			List<Requirements> allReqs = getDaoManager().getDataAccessManager().getRequirementsByProductId(productId);
			putOnSession("allReqs", allReqs);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
			break;
			
		case DataAccessConstants.EDIT_REQ_INFO:
			String requirement = (String) dataAccessMap.get("requirement");
			Requirements selectedRequirement = getDaoManager().getDataAccessManager().getRequirementByName(requirement);
			putOnSession("selectedRequirement", selectedRequirement);
			return selectedRequirement.getRequirement()+"~"+selectedRequirement.getId()+"~"+selectedRequirement.getStakeholder()+"~"+selectedRequirement.getDescription();
			
		case DataAccessConstants.TEAM:
			List<RelationMatrix> relationMatrix = getDaoManager().getProjectManager().getRelMatrixByProjectId(projectId);
			putOnSession("relationMatrix", relationMatrix);
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab7");
			break;
			
		case DataAccessConstants.RESOURCES:
			List<Resource> allResources = getDaoManager().getResourceManager().getResourcesByProductId(productId);
			putOnSession("allResources", allResources);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab6");
			break;
			
		case DataAccessConstants.PRIORITIZATION:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("matrixSize")!=null && dataAccessMap.get("elements")!=null){
				String matrixSize = (String)dataAccessMap.get("matrixSize");
				List<String> itemsList = new ArrayList<String>();
				String adaptedElements = (String)dataAccessMap.get("elements");
				String[] itemsArray = adaptedElements.split("~");
				for(int i=0; i<itemsArray.length; i++){
					itemsList.add(itemsArray[i]);
				}
				
				putOnSession("matrixSize", matrixSize);
				putOnSession("itemsList", itemsList);
			}
			
			if(dataAccessMap.get("activityName")!=null){
				List<AHPAnalysis> ahpByActName = getDaoManager().getDataAccessManager().getAHPByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("ahpByActName", ahpByActName);
			}
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
			break;
			
		case DataAccessConstants.ROADMAP:
			List<User> usersOnProject = getDaoManager().getUserManager().getUsersByProjectId(projectId);
			putOnSession("usersOnProject", usersOnProject);
			
			List<Roles> rolesOnProject = getDaoManager().getRoleManager().getRolesByProjectId(projectId);
			putOnSession("rolesOnProject", rolesOnProject);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab3");
			break;
			
		case DataAccessConstants.VOCT:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			

			if(dataAccessMap.get("activityName")!=null){
				List<VOCTable> vocByActName = getDaoManager().getDataAccessManager().getVOCByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("vocByActName", vocByActName);
			}
			
			List<Requirements> allRequirements = getDaoManager().getDataAccessManager().getRequirementsByProductId(productId);
			putOnSession("allReqs", allRequirements);
			
			List<VOCTable> allVOCLines = getDaoManager().getDataAccessManager().getVOCByProductId(productId);
			putOnSession("allVOCLines", allVOCLines);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.FUNCTIONS:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<ProductFunctions> functionsByActName = getDaoManager().getDataAccessManager().getFunctionsByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("functionsByActName", functionsByActName);
			}
			
			List<VOCTable> allVoct = getDaoManager().getDataAccessManager().getVOCByProductId(productId);
			putOnSession("allVOCLines", allVoct);
						
			List<ProductFunctions> allFunctions = getDaoManager().getDataAccessManager().getFunctionsByProductId(productId);
			putOnSession("allFunctions", allFunctions);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.CTQ:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<CTQs> ctqByActName = getDaoManager().getDataAccessManager().getCTQByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("ctqByActName", ctqByActName);
			}
			
			List<VOCTable> allVoctForCTQ = getDaoManager().getDataAccessManager().getVOCByProductId(productId);
			putOnSession("allVOCLines", allVoctForCTQ);
			
			List<CTQs> allCtqs = getDaoManager().getDataAccessManager().getCTQsByProductId(productId);
			putOnSession("allCtqs", allCtqs);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.DE:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<DesignElements> deByActName = getDaoManager().getDataAccessManager().getDEByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("deByActName", deByActName);
			}
			
			List<DesignElements> allDEs = getDaoManager().getDataAccessManager().getDEByProductId(productId);
			putOnSession("allDEs", allDEs);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.ACTIVITIES:
			List<Activity> allActivities = getDaoManager().getActivityManager().getActivitiesByProductId(productId);
			putOnSession("allActivities", allActivities);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.BLANK:
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.SHOW_SWOT:
			SwotAnalysis selectedSwotAnalysis = getDaoManager().getDataAccessManager().getSwotByNameandProdId(dataAccessMap.get("swotRequestName").toString(), productId);
			putOnSession("selectedSwot", selectedSwotAnalysis);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.CHECK_SWOT_STATUS:
			int check = 0;
			List<SwotAnalysis> swotByActivity = getDaoManager().getDataAccessManager().getSwotByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
			if(swotByActivity!=null){
				for(int i=0; i<swotByActivity.size(); i++){
					SwotAnalysis s = swotByActivity.get(i);
					if(!s.isStatus()){
						check = 1;
						break;
					}
				}
			}
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
			return check;
			
		case DataAccessConstants.GET_CHANGES:
			List<ChangeReport> cr = getDaoManager().getDataAccessManager().getCRByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
			String crResult = "";
			for (int i=0; i<(cr.size()-1); i++){
				ChangeReport c = cr.get(i);
				crResult+=c.getSubject()+"&xkw&"+c.getId()+"~";
			}
			ChangeReport c = cr.get(cr.size()-1);
			crResult+=c.getSubject()+"&xkw&"+c.getId();
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
			return crResult;
			
		case DataAccessConstants.GET_UNIQUE_REPORT:
			ChangeReport selectedReport = getDaoManager().getDataAccessManager().getCRBySubjectandProdId(Integer.valueOf(dataAccessMap.get("id").toString()), productId);
			putOnSession("selectedReport", selectedReport);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab4");
            break;
            
		case DataAccessConstants.PUGH:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			
			if((dataAccessMap.get("activityName")!=null)) {
				Activity thisActivity = getDaoManager().getActivityManager().getActivityByNameandProductId(dataAccessMap.get("activityName").toString(), productId);
				if(!thisActivity.getActivityLifeCycle().equals("In work")){
					PughAnalysis pughByActName = getDaoManager().getDataAccessManager().getPughByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
					putOnSession("pughByActName", pughByActName);
				}
			}
					
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.GET_PUGH:
			PughAnalysis currentPugh = getDaoManager().getDataAccessManager().getPughByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
            putOnSession("currentPugh", currentPugh);
            
            putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
			
		case DataAccessConstants.PRODUCT_FOLLOW_UP:
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab13");
            break;
            
		case DataAccessConstants.VIEW_PRODUCTION_DATA:
			List<ManufacturingItinerary> miByProdId = getDaoManager().getDataAccessManager().getMIByProductId(productId);
			putOnSession("miByProdId", miByProdId);
			
			List<Process> processByProdId = getDaoManager().getDataAccessManager().getProcessByProductId(productId);
			putOnSession("processByProdId", processByProdId);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab13");
            break;
            
		case DataAccessConstants.GET_USER_SUGGESTIONS:
			List<Suggestions> suggestionsByProdId = getDaoManager().getDataAccessManager().getSuggestionsByProdId(productId);
			putOnSession("suggestionsByProdId", suggestionsByProdId);
            
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab13");
            break;
            
		case DataAccessConstants.GET_USER_COMPLAINTS:
			List<Complaints> complaintsByProdId = getDaoManager().getDataAccessManager().getComplaintsByProdId(productId);
			putOnSession("complaintsByProdId", complaintsByProdId);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab13");
            break;
            
		case DataAccessConstants.CORRELATION_MATRIX:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				QFD qfdByActName = getDaoManager().getDataAccessManager().getQFDByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("qfdByActName", qfdByActName);
			}
            
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.REQ_VS_CTQ:
			List<Requirements> reqs = getDaoManager().getDataAccessManager().getRequirementsByProductId(productId);
			putOnSession("requirements", reqs);
			
			List<CTQs> ctqs = getDaoManager().getDataAccessManager().getCTQsByProductId(productId);
			putOnSession("ctqs", ctqs);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.CTQ_VS_FUNCTIONS:
			List<CTQs> ctqs1 = getDaoManager().getDataAccessManager().getCTQsByProductId(productId);
			putOnSession("ctqs", ctqs1);
			
			List<ProductFunctions> functions = getDaoManager().getDataAccessManager().getFunctionsByProductId(productId);
			putOnSession("functions", functions);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.FUNCTIONS_VS_DES:
			List<ProductFunctions> functions1 = getDaoManager().getDataAccessManager().getFunctionsByProductId(productId);
			putOnSession("functions", functions1);
			
			List<DesignElements> des = getDaoManager().getDataAccessManager().getDEByProductId(productId);
			putOnSession("des", des);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.SH_VS_DFX:
			List<Stakeholder> stakeholders = getDaoManager().getDataAccessManager().getStakeholdersByProductId(productId);
			putOnSession("stakeholders", stakeholders);
			
			List<DesignForX> dfxByProdId = getDaoManager().getDataAccessManager().getDfxByProdId(productId);
			putOnSession("dfxs", dfxByProdId);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.DFX_VS_GUIDELINES:
			List<DesignForX> dfxByProdId1 = getDaoManager().getDataAccessManager().getDfxByProdId(productId);
			putOnSession("dfxs", dfxByProdId1);
			
			List<DfXGuidelines> dfxGuidelinesByProdId = getDaoManager().getDataAccessManager().getDfXGuidelinesByProdId(productId);
			putOnSession("dfxGuidelines", dfxGuidelinesByProdId);
			
			List<DfXImportances> dfxImportancesByProdId = getDaoManager().getDataAccessManager().getDfXImportancesByProdId(productId);
			putOnSession("dfxImportances", dfxImportancesByProdId);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.DFX:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			List<DesignForX> allDFXInDB = getDaoManager().getDataAccessManager().getAllDfX();
			putOnSession("allDFXInDB", allDFXInDB);
			
			if(dataAccessMap.get("activityName")!=null){
				List<DfXRelMatrix> dfxRelMatrixByActName = getDaoManager().getDataAccessManager().dfxRelMatrixByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("dfxRelMatrixByActName", dfxRelMatrixByActName);
			}
            
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.GET_GUIDELINES:
			List<DfXGuidelines> guidelinesByDFXConcept = getDaoManager().getDataAccessManager().getGuidelinesByDfxId(Integer.valueOf(dataAccessMap.get("dfxId").toString()));
			putOnSession("guidelinesByDFXConcept", guidelinesByDFXConcept);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.GET_SPECIFIC_GUIDELINE:
			DfXGuidelines specificGuideline = getDaoManager().getDataAccessManager().getSpecificGuidelineById(Integer.valueOf(dataAccessMap.get("dfxGId").toString()));
			putOnSession("specificGuideline", specificGuideline);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.POPULATE_G_TABLE:
			String dfxIds[] = (String[])dataAccessMap.get("dfxIds");
			List<DesignForX> selDFX = getDaoManager().getDataAccessManager().getDfXByIds(dfxIds);
			putOnSession("selDFXById", selDFX);
			
			List<DfXGuidelines> guideByDfXId = getDaoManager().getDataAccessManager().getGuidelinesByDfxIds(dfxIds);
			putOnSession("guidelinesByDfXId", guideByDfXId);
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
            
		case DataAccessConstants.EXTERNAL_TOOL:
			activitiesForUser = getDaoManager().getActivityManager().getActivityByRoleandProductId(currentRole, productId);
			putOnSession("activitiesForUser", activitiesForUser);
			
			if(dataAccessMap.get("activityName")!=null){
				List<Resource> resByActName = getDaoManager().getDataAccessManager().getResourceByActNameandProdId(dataAccessMap.get("activityName").toString(), productId);
				putOnSession("resByActName", resByActName);
			}
			
			putOnState(ControllerConstants.NEXT_PAGE, "content/project/projectPage.jsp");
            putOnSession("currentTab", "tab5");
            break;
		}
		
		return null;
	}

}
